package palf.commands {
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;

import palf.visualEffects.layout.Layout;
import palf.visualEffects.utils.PositionData;

internal class ApplyLayout implements Command {

	private var target : DisplayObjectContainer;
	private var layout : Layout;

	public function ApplyLayout(target : DisplayObjectContainer, layout : Layout) {
		this.target = target;
		this.layout = layout;
	}

	public function execute() : void {
		var num_children : uint = target.numChildren;
		var child : DisplayObject;
		var data : PositionData;

		for (var i : uint = 0; i < num_children; i++) {
			child = target.getChildAt(i);
			data = layout.getLayoutData(i, child);
			child.x = data.x;
			child.y = data.y;
			child.rotation = data.rotation;
		}
	}

}

}
